<template>
  <div>{{ message }}</div>
  <button @click="sendMessage">给父组件发送消息</button>
</template>

<script setup>
defineProps({
  message:String
});

const emit=defineEmits(['message-sent']);
function sendMessage(){
  emit('message-sent','我是子组件发送的消息');
}
</script>